﻿using System;
using IOT4Week1Day1.Domain.Models;
using Microsoft.EntityFrameworkCore;

namespace IOT4Week1Day1.EFCore
{
    public class MyDbContext : DbContext
    {
        public MyDbContext( DbContextOptions<MyDbContext> options) : base(options)
        {
        }

        /// <summary>
        /// 是对模型类进行一些配置（ 配置迁移的映射规则）
        /// </summary>
        /// <param name="modelBuilder"></param>
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
        }

        /// <summary>
        /// 重写了基类的方法，  作用：对上下文进行一些配置，比如配置连接字符串
        /// </summary>
        /// <param name="optionsBuilder"></param>
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
        }


        //DbSet 属性
        public DbSet<User> Users { get; set; }
        public DbSet<AreaInfo>  AreaInfos { get; set; }

        public DbSet<Product>  Products { get; set; }

        public DbSet<ProductType>  ProductTypes { get; set; }
        public DbSet<DictKey>   DictKeys { get; set; }
        public DbSet<DictData>   DictDatas { get; set; }


    }
}
